package priv.demos.demo1.solution.main;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created on 2017/1/11.
 */
public class Main5 {

    public static void main(String[] args) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日HH点");
        String format = sdf.format(new Date());
        System.out.println("format = " + format);


        Calendar tmp = Calendar.getInstance();
        Calendar tmp1 = Calendar.getInstance();
        tmp.clear();
        tmp.set(tmp1.get(Calendar.YEAR),tmp1.get(Calendar.MONTH),tmp1.get(Calendar.DATE));

        System.out.println("tmp:"+sdf.format(tmp.getTime()));



        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        Date now = new Date();
        c1.setTime(now);
        c1.set(Calendar.HOUR, 0);
        c1.set(Calendar.MINUTE, 0);
        c1.set(Calendar.SECOND, 0);
        c1.set(Calendar.MILLISECOND, 0);
        c1.set(Calendar.DAY_OF_MONTH,17);
        System.out.println(sdf.format(c1.getTime()));

        c2.set(Calendar.HOUR, 0);
        c2.set(Calendar.MINUTE, 0);
        c2.set(Calendar.SECOND, 0);
        c2.set(Calendar.MILLISECOND, 0);
        System.out.println(sdf.format(c2.getTime()));

        System.out.println(c1.equals(c2));
        System.out.println(c1.compareTo(c2));
        System.out.println(c1.getTimeInMillis());
        System.out.println(c2.getTimeInMillis());
        System.out.println(c2.getTimeInMillis() == c1.getTimeInMillis());

        c2.add(Calendar.DATE,1);
        System.out.println(c1.equals(c2));
        System.out.println(c1.compareTo(c2));
        System.out.println(c1.getTimeInMillis());
        System.out.println(c2.getTimeInMillis());
        System.out.println(c2.getTimeInMillis() == c1.getTimeInMillis());

        c2.add(Calendar.DATE,1);
        c2.add(Calendar.DAY_OF_YEAR,1);
        System.out.println(c1.equals(c2));
        System.out.println(c1.compareTo(c2));
        System.out.println(c1.getTimeInMillis());
        System.out.println(c2.getTimeInMillis());
        System.out.println(c2.getTimeInMillis() == c1.getTimeInMillis());

    }
}